Almost finish 1.7 port
Fix building