haxe3 compatibility, it still needs some refactoring/bugfixing