Code cleanup and implementing cookie key config