Several big changes: closes #40 closes #27 closes #22 closes #8 closes #6 and other improvements.