Many many bug fixes and range functionality