Move up and clean some unused functions