Removed unused varibles and propagate exceptions