Making it work

Please ignore all the code formatting changes (sorry)