Initial version of the main scripts.

Must be merged into one script later.