refactor xplcore functions, add option to randomly generate instance id, fix call to mutex unlock when already unlocked in xplrx.c