Created a more efficient layering algorithm for the nucleus.