Fix warnings

Fix several warnings and one bug (using `respond_to?` instead of `method_defined?`)