Group inputs by destination
Updated code style and added unit test
Merge pull request #38 from thrykol/master

Group inputs by destination