Fix bug with using TileEntities

+Math helper class