Commits squashed, code style cleaned up, and manually rebased by Adam Honse <calcprogrammer1@gmail.com>