pforai: ported changes from real system to repo.
Merge pull request #3 from azet/master

pforai: ported changes from real system to repo.