More refactoring of core - simplified invalidate function. Moved examples to example folder.