Switch to external libraries, reorganize files