Separate ghost calculation and drawing
Various refactorings