prevent segfault when calling Rigidbody with incorrect argument type
small code cleanup
code refactoring