Updated to new Mongo Driver to take care of mongodb sometimes not shutting down on close. Seems to have fixed this issue.
Fixed the setVariable function so now variables should be correctly being written back to the database.