Fixed a number of bugs, but yet more to go