bugfixes
code cleanup
multi-threading support