refactored global data into functions in separate packages. also moved types and consts into separate packages