Added a function flushstream for emptying stdin (or other streams, if you'd like)
Better handling for username input.