3.0 working branch

Ready for version 2.5. Cleaner and faster code using less memory.