bug fix

forgot a register restoration
started memory management
Merge branch 'patch-2' of https://github.com/bungao/atlas2
first routines of memory management