Added caching, parts of a  REST api, and other small fixes