Refactoring and added option to upload pyramids