Further improvements and some first test code.