Added cache and defined data structure for layers