bugfixes and code introspection cleanup