fixes to error handling
preparing for function migration
moving bootstrap necessary functions to storage module temporarily
making almost all functions be loaded from models
making middleware model based
cleanup and reorganization