Restructured into 3 files