Close to finished code

Only minor tweaks left