Ubuntu compile

Just some changes to allow compile on Ubuntu for limits and threads.