Some more fixes and code cleanup. Probably stable, now.