Made StorageManager part of the document
Added select by layer
renamed some functions to make them more consistent