Various fixes and improvements. Still a long way to go :)