Rewritten entirely

It's now more modular and all inside one class. This will probably still
contain some bug...