Move loading of states and libs to own files