Prepared for v4 release

Bug fixes, performance improvements etc.