removed unused code
better typing and cleanup