Cleaned up recursive method.
Merge branch 'master' into dev