Almost there now
Some code cleanup as well