Misc fixes

tidying up frontend code, fixing a couple bugs