Implement last fixes and refacotrings to make JSHint happy (for now)