bug fixes and addressing chanleys code fixes