Fixed a few bugs that made layering break