code cleanup, toString bugfixing