Updated to work on linux (mostly variable case issues)