Modified to compile on OSX, added reset functionality