Added License (Apache), fixed bugs