Fix undefined var in findLayer
Add comments to logic functions
Use strict mode
Use regular JS for components instead of JSX
Reorder logic function
Move logic into layertree.js

The logic is too few LOC to warrant a separate file