Finished basic functionality
Added deadlock detection function