Fix getPosition called after finish, cleanup, add test cases, debug statements