some refactoring and correcting layer building
Merge pull request #1 from iolloyd/dev

some refactoring and correcting layer building