major bugfixes and typos patched