Major refactor into new layout