Define Maybe monade instance and refactor a bit