replaced Math.floor() with Std.int (where it's possible, at least i think it's safe)