Fixed thread statics

Thread statics were not compiling due to not being able to get a const reference to the memory instance. Fixed by adding a new function to get a const pointer. Required for thread static tests to pass in #728.