Fixed image defects and some macro refactoring