Added some stages in main
Re-organized the code a bit, added Process type