[#6] Fixed bugs in layer creation.