Huge refactor

reorganized files into multiple standalone libs