Optimizing tokenizer , issue #36

1) Fixed stack corruption in thread.c
2) Replaced read locks with write locks
3) Write lock is now released immediately after hashes swap
4) Consistent use of g_malloc/g_free instead of malloc/free
5) Print to error log (temporary)