Cleaned up by removing some unnecessary parts, updated sample/template and made it work with w3c sample