Removed conflicting memmanage declaration.
Added rudimentary exception-handling code.