Bug fixes and more aware code logic