Refactoring renderer.js.