Continued fixing bugs with help of berak. Should build fine now.