General fixes and file restructuring