added semaphore implementation and tons of dbg
Restructured everythang