Rewrite some core functionality
Write the logic for #5