Memory handling, code cleanup, etc.