MainLayer refactor

MainLayer refactor