Added multi-core support
Removed ununsed variables
Added comments