Applied suggestion and fixes by /u/N3G4 :)