fix montage generation and cleanup code