Refactor javascript classes into separate files