fixed up the formatting of the code
* moved some stuff around to better structure and cohere to the structure used by morgner