Modified dump func to drop from correct slots.

Cleaned main loop by moving loose commands into their own functions.
Changed variable names to fit their tasks.