Improve layers implementation