Fix inter-table references and add markupsafe lib