update comments and refactor memorycontext types