Implemented saving on collections and fixed some bugs