Added resource manager, refractored all code that involve cache so far
Merge heads