code cleanup and added rw perms for key file