Added license information
Added proper comments, fixed incorrectly setting attribute values