fixes sprite offset calculation code in Piece and refactors