move classes to ./lib and added cache hit detection