Improved layout of pattern generation, completed some misc. features for pattern generation.