failsafes added and some spacing
merged