Fixed 1.7 compatibility, added some comments and cache functionality