memory stuff + little fixes