Separated to functions

Moved one-time setup processes to a separate startup function.