Numerous fixes and even more junit tests (All passed \o/)