fixed bugs and added mac support