Re-organize and add a couple functions