Optimizations, some new features, bugfixes