Fixed many small bugs and brought external interfaces inline with recent changes