More test, bugfixes and better code formatting.