Fixed many issues that prevented compilation