Fixed minor issues and simplified