cleanups and command-line arguments

Small refactor that make it easier to read and also to integrate this code with other apps.
Feel free to ignore this PR if it's not relevant or needed. 
Ha. I just noticed that it should be arr.push(entry), not events (which is not globally available).
Also had to return arr; in the first if statement in saveEvents(). 
addEvent is better name