Bug fixes - almost entirely working now.