refactored Unsafe, fixed some generic notations