Changing API to return error codes (bool return value will also work)