Modified render function and added cache functions to Swift Class.