Refactore and add static library creation