Bug fixes and added License Header