General bugfixing and cleanup
General bugfixing and cleanup