Vastly cleaner code

Some major modifications have been made, and I've added several new
files.