made some updates to code after merging from upstream. Also changed image upload handling and optimized some javascript