Optimize loop
Optimize loop
Add missing newline
Remove unused variable
Fix unimplemented function returns, optimize some loops