Cleaned up code, pretty much done