added some comments and improved a small memory thing