Fixed exception handling and use Short generics for memory context