Added nanosleep alternative and removed str_error
Fixed infinite spawn and logging