refs and code cleanup
Merge branch 'cleanup' into develop