Added layers, fixed bugs