Fixes and code simplified