More code separation; Ironing some small bugs