major refactor
fix last few bugs from refactor