fixed possible race condition
added reset command to the library