fixed tile caching and unused variables