Some small refactoring. Still a lot of C++ eye-bleed. Sorry about that.