Added memory support.

Abstracted general functionalities.
Added testing.
Updated docs.