Refactored liblwes core and reduced call overhead