Code refactoring + ruby support