Flux Layout - code refactoring

Bug swatting and code tidying.