some bugfixes - this tool will probably be completely rewritten soon, but is at least somewhat useful right now