Rewrote lots of code. Unified main files into one.