Refactored all functions. Fixed templates to use images. Model fully implemented.