Modularize

Make a module for core functions.