refactoring

- refactoring: breaking out functions
- worked on stability enhancements
- graph and output scaled to mA/cm^2
- many other small changes