Fixes some bugs - still more to go!