Bug fixes.
Used wait_for_state function instead a hardcoded timeout.
Removed some comments and old code.
Included some extra log messages.