Refactor the code
Add Capistrano v2/v3 support