Complete rewrite, much cleaner and lots of new features