Added some bangs in monads and tidied up code