Code optimization, minor bug fix.