Initial layout change and code cleanup

Changed the way the initial sets are arranged and cleaned up the code
with some speed improvements.