improved library handling, refactored mosts things to libraries, removed global hooks