Extract some functions from render() methods
Prepare for merge to master, git bisect