clean up and added functionality for layered rendering
Merge origin/master