Refactor packages + fix system exit for batchmain