Clean-up, bug fixes.
Testes added, cleanup.