Wrap everything in functions and set cache and data via function calls, we need to wait to call buildCache until the map has loaded