Fix wrong type definitions and invalid return value