removed unnecessary function ApplyGravity, code cleanup