Refactor and reorganize

Change: Double to double, Int32 to int for simplicity.
Change: more whitespace in system generation code.