Fixed threading + compilig errors + added makefile