lsp: reorganized code, added new sorting
lsp: style fixes