More structuring and bug fixing for syntax