Bug fixes

Code cleaning & bug fixes