Major fixes, working version reached