Reformatting and refactoring, and adding image support