Cleaned up code and made compiling