got rid of semaphores, used LOCK_EX flag instead