Fixed a bug and moved some classes into their own files