fix bugs and refactor
Merge branch 'master' into gh-pages

Conflicts:
	demo/app.build.js
	index.html
	tests/testBuild.js