cleanup, bugfixes and documentation