Housekeeping, remove duplicate function.
Minor changes and clean up